home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 49 / Amiga Format CD49 (2000-01-17)(Future Publishing)(GB)(Track 1 of 3)[!][issue 2000-02].iso / -serious- / graphics / amicad / arexx_english / duplicate.amicad < prev    next >
Text File  |  1999-12-06  |  3KB  |  160 lines

  1. /* Clonage d'un composant, en "augmentant sa référence"
  2. $VER: 1.01e (© R.Florac, 22 mai 1999) */
  3.  
  4. options results     /* indispensable pour récupérer le résultat des macros */
  5.  
  6. signal on error     /* pour l'interception des erreurs */
  7. signal on syntax
  8.  
  9. 'FIRSTSEL'
  10. o=result
  11. if o=0 then do
  12.     'MESSAGE("Select the"+CHR(10)+"component to copy !")'
  13.     exit
  14. end
  15.  
  16. type=0
  17. do while type=0
  18.     'TYPE('o')'
  19.     select
  20.     when result=1 then do
  21.         type=1
  22.         leave
  23.     end
  24.     when result=4 then do
  25.         type=4
  26.         leave
  27.     end
  28.     when result=11 then do
  29.         type=11
  30.         leave
  31.     end
  32.     when result=12 then do
  33.         type=12
  34.         leave
  35.     end
  36.     otherwise nop
  37.     end
  38.     'NEXTSEL('o')'; o=result
  39.     if o=0 then do
  40.     'MESSAGE("Incorrect selection")'
  41.     exit
  42.     end
  43. end
  44.  
  45. if type=1 then 'READTEXT(GETREF('o'))'
  46. else 'READTEXT('o')'
  47. ref=result
  48. j=numero_reference(ref)
  49. ref=reference(ref)
  50. 'WIDTH(0)'; l=(result%10)*10
  51. 'HEIGHT(0)'; h=(result%10)*10
  52. 'COL(0)'; x0=result
  53. 'LINE(0)'; y0=result
  54. 'SELECT("Copy direction"+CHR(10)+"Bottom"+CHR(10)+"Right"+CHR(10)+"Up"+CHR(10)+"Left")'
  55. sens=result
  56. if sens < 1 then exit
  57. 'ASKNUM("How many times"+CHR(10)+"do you want to do"+CHR(10)+"the operation?",2)'
  58. n=result
  59. if n<1 then exit
  60. 'SELECT("Step beetween copies"+CHR(10)+"10 pixels"+CHR(10)+"20 pixels"+CHR(10)+"30 pixels"+CHR(10)+"Automatic"+CHR(10)+"Specified")'
  61. pas = result
  62. select
  63.     when pas=1 then pas=0
  64.     when pas=2 then pas=10
  65.     when pas=3 then pas=20
  66.     when pas=4 then do
  67.     if sens=1 | sens=3 then pas=h
  68.     else pas=l
  69.     end
  70.     when pas=5 then do
  71.     'ASKNUM("Step beetween copies",10)'
  72.     pas=result
  73.     end
  74.     otherwise exit
  75. end
  76.  
  77. 'COPY(5)'           /* sauvegarde des éléments à copier */
  78. 'SAVEALL(-1)'
  79. do i=1 to n
  80.     select
  81.     when sens=1 then do    /* Copie vers le bas */
  82.         yy=y0+(10+pas)*i
  83.         yy=(yy%10)*10
  84.         'PASTE(5,'x0','yy')'
  85.     end
  86.     when sens=2 then do
  87.         xx=x0+(10+pas)*i
  88.         xx=(xx%10)*10
  89.         'PASTE(5,'xx','y0')'
  90.     end
  91.     when sens=3 then do
  92.         yy=y0-(10+pas)*i
  93.         yy=(yy%10)*10
  94.         'PASTE(5,'x0','yy')'
  95.     end
  96.     otherwise do
  97.         'MESSAGE("Not allready implemented!")'
  98.     end
  99.     end
  100.     if ref ~= "" then do
  101.     j=j+1
  102.     k=indice(type)
  103.     if type=1 then 'SETREF('k',"'ref||j'"):UNMARK(-1)'
  104.     else 'SETTEXT('k',"'ref||j'"):UNMARK(-1)'
  105.     end
  106. end
  107.  
  108. exit
  109.  
  110. indice: procedure
  111.     parse arg type
  112.     'FIRSTSEL'
  113.     o=result
  114.     do while o>0
  115.     'TYPE('o')'
  116.     select
  117.         when result=type then return o
  118.         otherwise nop
  119.     end
  120.     'NEXTSEL('o')'; o=result
  121.     end
  122.     return 0
  123.  
  124. reference: procedure
  125.     parse arg ref
  126.     i=length(ref)
  127.     do while i>1
  128.     c=substr(ref,i,1)
  129.     if datatype(c)=NUM then ref=left(ref,i-1)
  130.     else return ref
  131.     i=i-1
  132.     end
  133.     return ref
  134.  
  135. numero_reference: procedure
  136.     parse arg ref
  137.     i=length(ref)
  138.     r=0
  139.     rang=1
  140.     do while i>1
  141.     c=substr(ref,i,1)
  142.     if datatype(c)=NUM then do
  143.         r=r+c*rang
  144.         rang=rang*10
  145.     end
  146.     else return r
  147.     i=i-1
  148.     end
  149.     return r
  150.  
  151. /* Traitement des erreurs, interruption du programme */
  152. syntax:
  153. erreur=RC
  154. 'MESSAGE("Script Duplicate.AmiCAD"+CHR(10)+"Syntax error"+CHR(10)+"en ligne 'SIGL'"+CHR(10)+"'errortext(erreur)'")'
  155. exit
  156.  
  157. error:
  158. 'MESSAGE("Script Duplicate.AmiCAD"+CHR(10)+"Error in line 'SIGL'")'
  159. exit
  160.